package com.szh.cloud.spring.util;

import com.obs.services.ObsClient;
import com.obs.services.model.ObjectListing;
import com.obs.services.model.ObsObject;

import java.util.List;

public class ObsUtil {
    private static  final  String endpoint="obs.cn-north-4.myhuaweicloud.com";
    private static  final  String  ak = "YMWJFZ2WRJWNPHT1BOHT";
    private static  final  String  sk = "Ma2Bl8VLnhrfmMsL17Pt0p8WTnBGhiV58fQNB20b";
    private static  final  String  bucketName = "java-1201";

    public static void main(String[] args) {
        ObsClient obsClient = new ObsClient(ak,sk,endpoint);
        ObjectListing list = obsClient.listObjects(bucketName);
        List<ObsObject> listObjects = list.getObjects();
        for(ObsObject obsObject:listObjects){
            System.out.println("obsKey:" + obsObject.getObjectKey());
            System.out.println("obsSize:"  + obsObject.getMetadata().getContentLength());
        }

    }
}